<div>
	<?if($student_grades):?>
		
	<div class="table-responsive">

		<table class="table table-compressed table-bordered">
			<tr class="info">
				<td colspan="2" style="font-weight:bold;">LEARNING AREAS</td>
					<?foreach($gp as $k=>$v):?>
						<td  style="font-weight:bold;"><?=strtoupper($v->gp_code);?></td>
					<?endforeach;?>
				<?if(strtolower($sec->grade_type) === "smiley"):?>
				<?else:?>
					<td style="font-weight:bold;">FINAL</td>
				<?endif;?>
			</tr>
			
			<?if($student_grades):?>

				<?foreach ($student_grades as $key => $value):?>
					<tr id='<?=$value['sub_id'];?>'>

						<td colspan="2"><?=$value['name'];?></td>

						<?if($value['grades']):?>
							
							<? /* Grading Type is SMILEY */ ?>	
							<?if(strtolower($sec->grade_type) === "smiley"):?>

								<?foreach($value['grades'] as $grading_p_id => $v):?>
									<?php if($grading_p_id == "final"){ continue; } // Skip Final, no final for kinder ?>
									<td><?=_smiley($v->value);?></td>
								<?endforeach;?>
							
							<? /* Grading Type is NUMERIC */ ?>
							<?else:?>
							
								<?$final_pass = 0; foreach($value['grades'] as $grading_p_id => $v):?>

									<td>

											<?if($grading_p_id == "final"): $final_pass++;?> <? /* Final Average Compute in the model */ ?>
												<div class="btn-group">
													<!-- <button tabindex="-1" class="btn btn-mini"><span class="badge"><?=$v;?></span></button> -->
													<span class="badge badge-info"><?=_convert($v);?></span>
												</div>
											<?else:?>
												
												<!-- <button tabindex="-1" class="btn btn-mini"><span class="badge badge-inverse"><?=$v->value;?></span></button> -->
												<span class="badge badge-success"><?=_convert($v->value);?></span>
												
											<?endif;?>

									</td>
								<?endforeach;?>

							<?if($final_pass <=0):?> <? /* EXtra TD */ ?>
								<td></td>
							<?endif;?>

							<?endif;?>

						<?else:?>

						<?endif;?>

					</tr>
				<?endforeach;?>
			<?else:?>
				<tr>
					<td colspan="<?=count($value['grades'] + 2);?>">
						<div class="alert alert-danger"><i class="fa fa-warning"></i>&nbsp; Unable to create student grades. No subjects available in the curriculum for this student year level.</div>
					</td>
				</tr>
			<?endif;?>
		</table>

	</div>

	<?else:?>
		<div class="alert alert-warning">Unable to get student Grades. Because 1) Student is not assigned to a section, 2) student is not allowed to view grades and remarks.</div>
	<?endif;?>
</div>